package work.mediway.bi.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mediway.hos.base.model.BaseResponse;
import org.springframework.web.bind.annotation.*;
import work.mediway.bi.model.dto.InterfaceOperDTO;
import work.mediway.bi.model.entity.InterfaceOper;
import work.mediway.bi.model.vo.InterfaceOperVO;
import work.mediway.bi.service.InterfaceOperService;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * @author bovane <bovane.ch@gmail.com>
 * @description BI-Design 界面操作相关接口
 * @create 2023-06-13 16:55
 */
@Slf4j
@RestController
@RequestMapping("/bi/design")
public class BiDesignOperController {

    @Resource
    private InterfaceOperService interfaceOperService;

    /**
     * 获取页面设计详细信息
     */
    @GetMapping()
    public BaseResponse getInfo(InterfaceOperDTO interfaceOperDTO) {
        IPage<InterfaceOperVO> result =  this.interfaceOperService.getInterfaceOper(interfaceOperDTO);
        return BaseResponse.success(result);
    }


    /**
     * 新增页面设计信息
     */
    @PostMapping
    public BaseResponse add(@RequestBody InterfaceOper interfaceOper) {
        //保存基本信息
        Boolean result = this.interfaceOperService.addInterfaceOper(interfaceOper);
        return result ? BaseResponse.success(): BaseResponse.error();
    }

    /**
     * 更新页面设计信息
     */
    @PutMapping
    public BaseResponse edit(@RequestBody InterfaceOper interfaceOper) {
        Boolean result = this.interfaceOperService.updateInterfaceOper(interfaceOper);
        return result ? BaseResponse.success(): BaseResponse.error();
    }

    /**
     * 删除页面设计信息,多条则以 "," 作为分割
     */
    @DeleteMapping("/{ids}")
    public BaseResponse remove(@PathVariable String ids) {
        this.interfaceOperService.deleteinterfaceOper(ids);
        return BaseResponse.success();
    }

}
